import 'package:json_annotation/json_annotation.dart';

part 'user_model.g.dart';

@JsonSerializable()
class UserModel {
  final String accessToken;
  final String platformId;
  String userName;
  final String userType;
  final String mobile;
  String avatar;
  final bool needSetPassword;
  final bool needBindMobile;
  final String shareCode;
  final bool disable;

  UserModel({
    required this.accessToken,
    required this.platformId,
    required this.userName,
    required this.userType,
    required this.mobile,
    required this.avatar,
    required this.needSetPassword,
    required this.needBindMobile,
    required this.shareCode,
    required this.disable,
  });

  // 添加更新方法
  UserModel copyWith({
    String? userName,
    String? avatar,
  }) {
    return UserModel(
      accessToken: accessToken,
      platformId: platformId,
      userName: userName ?? this.userName,
      userType: userType,
      mobile: mobile,
      avatar: avatar ?? this.avatar,
      needSetPassword: needSetPassword,
      needBindMobile: needBindMobile,
      shareCode: shareCode,
      disable: disable,
    );
  }

  factory UserModel.fromJson(Map<String, dynamic> json) =>
      _$UserModelFromJson(json);

  Map<String, dynamic> toJson() => _$UserModelToJson(this);
}